<template>
	<view>
		<view class="pop_bg" v-show='head' @tap="closeNavSwitch" @touchmove.stop.prevent=''>
			<view class="pop_bg_item1 pop_bg_item_left">
				<view class="left_item" v-for="(item, index) in titledata" :key="index" @tap.stop="gotocreate(index)">{{item.title}}</view>
			</view>
		</view>
		<view class="title">{{zname}}</view>
		<view class="cont">
			<view class="quesTitle">
				<view class="typeView">
					<view class="typeName">{{quesDetail.typeName}}</view>
					<view class="notes"><i class="iconfont iconcuowu"></i>题目有错，<text>我要纠错</text></view>
				</view>
				<uni-rate :readonly="true" :value="quesDetail.question_level" :max="5" :size="22"></uni-rate>
			</view>
			<view class="quesCont" v-html="quesDetail.question_title"></view>
			<view class="answer"><text>正确答案：</text><view v-html="quesDetail.answer"></view></view>
			<view class="quesTitle">
				<view class="typeView">
					<view class="typeName">题目解析</view>
					<view class="notes"><i class="iconfont iconcuowu"></i>解析有错，<text>我要纠错</text></view>
				</view>
			</view>
			<view class="quesAnaly" v-html="quesDetail.question_analysis"></view>
		</view>
	</view>
</template>

<script>
	import util from '@/common/util.js';
	import uniRate from '../../components/uni-rate/uni-rate.vue'
	export default{
		data() {
			return {
				titledata: [
					{title:'上传资源'},
					{title:"查看资源"},
				],
				head: false,
				question_id: '',
				fname: '',
				zname: '',
				quesDetail: {}
			}
		},
		components: {
			uniRate
		},
		onNavigationBarButtonTap() {
			this.head = !this.head
			this.$forceUpdate();
		},
		onLoad(e) {
			this.fname = e.name;
			uni.setNavigationBarTitle({
				title: this.fname
			})
			this.zname = e.zname;
			this.question_id = e.question_id;
			this.getDetail();
		},
		methods: {
			/* 试题详情 */
			getDetail() {
				var data = {
					question_id: this.question_id,
					is_get_answer: 2
				}
				this.$zapi.apiPost('user/question.Lists/questionList',data).then(res=>{
					if(res.data.code == 200) {
						var list = res.data.data.data;
						for (let j = 0; j < list.length; j++) {
							list[j].interest_lists_log = [];
						}
						util.latex_reques(list,'question_title');//解析 试题标题 latex 公式转换
						util.latex_reques(list,'question_analysis');//解析 试题解析 latex 公式转换
						util.latex_answer(list,'answer_list');//解析答案选项 latex 公式转换
						var arr = util.getAnalysis(list);
						this.quesDetail = arr[0];
						this.quesDetail.typeName = util.getTypeName(this.quesDetail.question_typeid);
					} else {
						uni.showToast({
							title: res.data.msg,
							icon: 'none'
						})
					}
				})
			},
			/* 关闭蒙版 */
			closeNavSwitch() {
				this.head = false
			},
			/* 导航栏右侧按钮点击事件 */
			gotocreate:function(index){
				this.head = !this.head;
				if(index == 0){
					uni.navigateTo({
						url: 'upload?question_id='+this.question_id
					})
				}
				if(index == 1){
					uni.navigateTo({
						url: 'resources?question_id='+this.question_id
					})
				}
			}
		}
	}
</script>

<style>
	/* page{
		background: #FAFAFA;
	} */
	/* 蒙版 */
	.pop_bg {
		position: fixed;
		z-index: 600;
		width: 100%;
		height: 100%;
		background-color: rgba(0, 0, 0, .5);
	}
	.pop_bg_item1 {
		position: absolute;
		right: 20upx;
		margin-top: 20upx;
		width:30%;
		background-color: #ffffff;
		border-radius: 5upx;
	}
	.pop_bg_item1:before {
		content: "";
		position: absolute;
		display: inline-block;
		border-width: 18upx;
		border-style: solid;
		border-color: white transparent transparent transparent;
		transform: rotate(180deg);
		top: -30upx;
	}
	.pop_bg_item_left:before {
		right: 5%;
	}
	.left_item {
		display: flex;
		justify-content: center;
		align-items: center;
		position: relative;
		width: 100%;
		font-size: 32upx;
		padding: 15upx 0;
		color: #333333;
	}
	/* 试题 */
	.title{
		color: #666666;
		font-size: 34upx;
		padding: 20upx 30upx;
		border-bottom: 2upx solid #E5E5E5;
		background-color: #FFFFFF;
	}
	.cont{
		padding: 0 30upx;
		width: 690upx;
		background-color: #FFFFFF;
		padding-bottom: 80upx;
	}
	.quesTitle{
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 20upx 0;
	}
	.typeView{
		display: flex;
		justify-content: flex-start;
	}
	.typeName{
		color: #333333;
		font-size: 36upx;
	}
	.typeName:before{
		content: '|';
		height: 36upx;
		color: #00ACFE;
		margin-right: 10upx;
	}
	.notes{
		color: #CCCCCC;
		font-size: 22upx;
		margin-top: 10upx;
		margin-left: 12upx;
		display: flex;
		align-items: center;
		line-height: 1;
	}
	.notes .iconcuowu{
		font-size: 32upx;
	}
	.notes text{
		color: #FF9900;
	}
	.uni-rate-icon{
		margin-right: 5upx !important;
	}
	.quesCont{
		color: #333333;
		font-size: 36upx;
	}
	.answer{
		color: #00D5A2;
		font-size: 34upx;
		padding: 40upx 0;
		display: flex;
		justify-content: flex-start;
	}
	.answer text{
		white-space: nowrap;
	}
	.answer view{
		color: #00D5A2;
		font-size: 34upx;
	}
	.quesAnaly{
		color: #666666;
		font-size: 34upx;
	}
</style>
